As strings are guaranteed to use UTF-8 in the GNOME platform, generic
file APIs like g_file_load_contents() return raw data instead. Since
gjs' recent update to mozjs60, this data is now returns as Uint8Array
which cannot simply be treated as string - its toString() method boils
down to arr.join(',') - so use gjs' new ByteArray module to explicitly
convert the data.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/179
let metadataContents, success, tag;
try {
[success, metadataContents, tag] = metadataFile.load_contents(null);
+ if (metadataContents instanceof Uint8Array)
+ metadataContents = imports.byteArray.toString(metadataContents);
} catch (e) {
throw new Error('Failed to load metadata.json: ' + e);
}
_loadModel(groupName) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
let [success, contents] = file.load_contents(null);
+ if (contents instanceof Uint8Array)
+ contents = imports.byteArray.toString(contents);
return JSON.parse(contents);
},
_init(params) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
let [success, css, etag] = file.load_contents(null);
+ if (css instanceof Uint8Array)
+ css = imports.byteArray.toString(css);
this._curEdited = null;
this._prevEdited = null;
this._css = css;
let fileContent, success, tag, newMode;
try {
[success, fileContent, tag] = file.load_contents(null);
+ if (fileContent instanceof Uint8Array)
+ fileContent = imports.byteArray.toString(fileContent);
newMode = JSON.parse(fileContent);
} catch(e) {
return;